package com.arron.algorithm.leetcodetop100.二叉树;

import com.arron.algorithm.tree.TreeNode;

/**
 * leetcode 101 ：对称二叉树
 */
public class SymmetricTree {


    public boolean isSymmetric(TreeNode root) {
        if (root == null){
            return true;
        }
        return isSymmetric(root.right,root.left);
    }

    public boolean isSymmetric(TreeNode left,TreeNode right){
        if (left == null && right ==null ){
            return true;
        }
        if (left == null || right ==null){
            return false;
        }

        if (left.val != right.val){
            return false;
        }
        return isSymmetric(left.left,right.right) && isSymmetric(left.right,right.left);
    }


}
